#include <iostream>
using namespace std;
const int N=64;
int main()
{int n,t=0,a[N];
  cin>>n;
  cout<<endl;
 {for (int i=1;i<=n;i++)
   cin>>a[i];
  } 
  cout<<endl;
  cout<<"0";
  cout<<endl;
  for (int j=1;j<=n-1;j++)
    {for (int i=1;i<=n-j;i++)
       if(a[i]>=a[i+1])
       {t=a[i];a[i]=a[i+1];a[i+1]=t;}
     }
 cout<<a[1]+a[n]<<endl;
 system ("pause");
 return 0;
}
